class Solution {
public:
    int numberOfArithmeticSlices(vector<int>& nums) {
        vector<int>dp(nums.size());
        int ret=0;
        for(int i=2;i<nums.size();i++)
        {
            dp[i]=(nums[i]-nums[i-1]==nums[i-1]-nums[i-2])?dp[i-1]+1:0;
            ret+=dp[i];
        }
        return ret;
    }
};
